package com.sj.uabrowser.mvp.wea.loader;

import com.sj.uabrowser.framework.BaseLoader;
import com.sj.uabrowser.framework.BasePresenter;
import com.sj.uabrowser.net.AuthResultClient;
import com.sj.uabrowser.net.ServiceApi;

import java.util.HashMap;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;

public class MainLoader extends BaseLoader {

    public MainLoader(BasePresenter mPresenter) {
        super(mPresenter);
    }

    public void mainInfo2(final int requestId, String id) {
        AuthResultClient.getService4(ServiceApi.class)
                .fetchMainContent2(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<ResponseBody>() {
                    @Override
                    public void accept(ResponseBody mainFunc) throws Exception {
                        if(mPresenter!=null)
                            mPresenter.onDataCallBack(requestId,mainFunc);
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        if(mPresenter!=null)
                            mPresenter.onDataCallBackError(requestId,throwable);
                    }
                });
    }

}
